﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
    <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/uuid.js"></script>
</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">ID</label>
            <div class="layui-input-inline">
                <input type="text" id="id" lay-verify="" placeholder="ID" disabled autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" id="user_name" name="user_name" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" id="user_pwd" name="user_pwd" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input" value="">
            </div>
            <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认</label>
            <div class="layui-input-inline">
                <input type="password" lay-verify="" placeholder="请再输入密码" autocomplete="off" class="layui-input" value="">
            </div>
            <div class="layui-form-mid layui-word-aux">确认密码</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline">
                <input type="text" id="user_email" name="user_email" lay-verify="email" placeholder="" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-inline">
                <input type="text" id="time"  placeholder="" autocomplete="off" disabled class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="publish" lay-submit="" lay-filter="tijiao">修改</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        </form>
        <script type="text/javascript" src="plugins/layui/layui.js"></script>
    <script src="ajax/main.js"></script>
        <script>

            layui.use(['form', 'layer'], function () {
                var form = layui.form(),
					layer = parent.layer === undefined ? layui.layer : parent.layer;
                var JsonData = {};
                var mid = $.GetQueryString.Get("mid");
                var idx = $.GetQueryString.Get("idx");
                var idList = $.GetQueryString.Get("idList").split(",");
                var frameID = $("li[class='layui-this']", parent.document).children("i").last().attr("data-id");
                $("iframe[data-id='" + frameID + "']", parent.document).contents().find("#dynamic-table tr:gt(0):eq(" + idx + ") td").each(function (index) {
                    if (index == 0) { JsonData[idList[index]] = mid; } else if (index <= 4) { JsonData[idList[index]] = $(this).text(); }
                });
                //绑定表单
                $.each(JsonData, function (index, item) {
                    $("#" + index).val(item);
                });
                //自定义验证规则
                form.verify({
                    title: function (value) {
                        if (value.length < 5) {
                            return '标题至少得5个字符啊';
                        }
                    },
                    pass: [/(.+){6,12}$/, '密码必须6到12位'],
                    content: function (value) {
                        layedit.sync(editIndex);
                    }
                });
                
                //监听提交
                form.on('submit(tijiao)', function (data) {
                    var v = null;
                    $.each(data.field, function (index, objVal) {
                        v == null ? v =  index + "=" + "'" + objVal + "'" : v = v + ',' +  index + "=" + "'" + objVal + "'";
                    });
                    var d = new Date();
                    var s = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes();
                    CJPlugin.execute("admin", v, "update", "ExecuteHandler", $("#id").val());
                    //layer.alert(JSON.stringify(data.field), {
                    //    title: '最终的提交信息'
                    //})
                    return false;
                });
            });
            jQuery.GetQueryString = {
                Get: function (name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                }
            }
        </script>
</body>
</html>
